package com.ruoyi.cmemetal.controller;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.web.controller.monitor.SysOperlogController;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cmemetal.domain.ZxOrderForm;
import com.ruoyi.cmemetal.service.IZxOrderFormService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * orderController
 *
 * @author zhangxu
 * @date 2021-12-08
 */
@RestController
@RequestMapping("/order/form")
public class ZxOrderFormController extends BaseController
{
    @Autowired
    private IZxOrderFormService zxOrderFormService;

    /**
     * 查询order列表
     */
    @PreAuthorize("@ss.hasPermi('order:form:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxOrderForm zxOrderForm)
    {
        startPage();
        List<ZxOrderForm> list = zxOrderFormService.selectZxOrderFormList(zxOrderForm);

        return getDataTable(list);
    }

    /**
     * 导出order列表
     */
    @PreAuthorize("@ss.hasPermi('order:form:export')")
    @Log(title = "order", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxOrderForm zxOrderForm)
    {
        List<ZxOrderForm> list = zxOrderFormService.selectZxOrderFormList(zxOrderForm);
        ExcelUtil<ZxOrderForm> util = new ExcelUtil<ZxOrderForm>(ZxOrderForm.class);
        util.exportExcel(response, list, "order数据");
    }

    /**
     * 获取order详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:form:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zxOrderFormService.selectZxOrderFormById(id));
    }

    /**
     * 新增order
     */
    @PreAuthorize("@ss.hasPermi('order:form:add')")
    @Log(title = "order", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxOrderForm zxOrderForm)
    {
        return toAjax(zxOrderFormService.insertZxOrderForm(zxOrderForm));
    }

    /**
     * 修改order
     */
    @PreAuthorize("@ss.hasPermi('order:form:edit')")
    @Log(title = "order", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZxOrderForm zxOrderForm)
    {
        return toAjax(zxOrderFormService.updateZxOrderForm(zxOrderForm));
    }

    /**
     * 删除order
     */
    @PreAuthorize("@ss.hasPermi('order:form:remove')")
    @Log(title = "order", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        AjaxResult ajaxResult = toAjax(zxOrderFormService.deleteZxOrderFormByIds(ids));
        return ajaxResult;
    }

}
